package com.rongzhe.house.ui.activity;

import android.os.Bundle;
import android.support.annotation.Nullable;

import com.rongzhe.house.R;
import com.rongzhe.house.entity.LifeServiceBanner;
import com.rongzhe.house.presenter.LifeServicePresenter;
import com.rongzhe.house.ui.view.BannerView;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by huang on 2017/12/14.
 */

public class LifeServiceActivity extends BaseActivity<LifeServicePresenter> {
    @BindView(R.id.banner_house_moving)
    BannerView bannerHouseMoving;
    @BindView(R.id.banner_cleaning)
    BannerView bannerCleaning;
    @BindView(R.id.banner_repair)
    BannerView bannerRepair;

    @Override
    protected LifeServicePresenter createPresenter() {
        return new LifeServicePresenter(this);
    }

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_life_serivce);
        ButterKnife.bind(this);
    }

    public void setHouseMovingData(int bannerType, List<LifeServiceBanner> datas) {
        if (datas == null || datas.size() <= 0) {
            return;
        }
        if (bannerType == LifeServiceBanner.Companion.getHouseMoving()) {
            bannerHouseMoving.setDatas(getLifeServiceBannerUrl(datas));
        } else if (bannerType == LifeServiceBanner.Companion.getCleaning()) {
            bannerCleaning.setDatas(getLifeServiceBannerUrl(datas));
        } else if (bannerType == LifeServiceBanner.Companion.getRepair()) {
            bannerRepair.setDatas(getLifeServiceBannerUrl(datas));
        }
    }

    private  List<BannerView.BannerData> getLifeServiceBannerUrl(List<LifeServiceBanner> datas) {
        List<BannerView.BannerData> bannerDatas = new ArrayList<>();
        for (int i = 0; i < datas.size(); i++) {
            bannerDatas.add(new BannerView.BannerData(-1, datas.get(i).getImageUrl(), "http:www.baidu.com"));
        }
        return bannerDatas;
    }

    @Override
    protected String getActionTitle() {
        return getString(R.string.life_service);
    }
}
